from unit__003.unit_05.Base.Base import Base
from selenium.webdriver.common.by import By
import time

class Page(Base):

    # 元素定位
    # 封装元素的操作方法

    search_loc=(By.ID,'kw')
    def sr_search(self):
        self.send_keys(self.search_loc,'UI自动化测试')

    # 点击搜索 id="su"
    ss_loc=(By.ID,'su')
    def click_ss(self):
        self.click(self.ss_loc)

    # 对搜索框内容全选操作
    def srk_qx(self):
        self.ctrl_a(self.search_loc)

    # 对搜索框内容复制操作
    def srk_fz(self):
        self.ctrl_c(self.search_loc)

    # 对设置元素进行鼠标悬停操作 name="tj_settingicon"
    set_loc=(By.NAME,'tj_settingicon')
    def set_move(self):
        self.move_to_element(self.set_loc)

    # 点击高级搜索 //*[@id="u"]/div[3]/a[2]/span
    gjss_loc=(By.LINK_TEXT,'高级搜索')
    def click_gjss(self):
        self.click(self.gjss_loc)

    # 复制到输入框 id="adv_keyword"
    zantie_loc=(By.ID,'adv_keyword')
    def srk_zantie(self):
        self.ctrl_v(self.zantie_loc)



    # 百度 逻辑业务
    def baidu_luoji(self):
        self.open_url('https://www.baidu.com/')
        time.sleep(2)
        self.sr_search()
        time.sleep(2)
        self.click_ss()
        time.sleep(2)
        self.srk_qx()
        time.sleep(2)
        self.srk_fz()
        time.sleep(2)
        self.set_move()
        time.sleep(2)
        self.click_gjss()
        time.sleep(2)
        self.srk_zantie()
        time.sleep(2)

